package com.naizhuai.ui.user.multtype;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.naizhuai.Model.AccountHelper;
import com.naizhuai.Model.db.user.PersonUserBean;
import com.naizhuai.R;
import com.naizhuai.ui.mianbusiness.setting.PersonRadarActivity;
import com.naizhuai.ui.rank.RankActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import me.drakeet.multitype.ItemViewBinder;

/**
 * @author：lichenxi
 * @date 2018/5/28 15
 * email：525603977@qq.com
 * Fighting
 */
public class AchieveMentViewBinder extends ItemViewBinder<String, AchieveMentViewBinder.ViewHolder> {
    private ClickCallback mClickCallback;
    public AchieveMentViewBinder(ClickCallback clickCallback) {
        this.mClickCallback=clickCallback;
    }

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.info_item_achieve_ment, parent, false);
        return new ViewHolder(root);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull String result) {
        holder.raderContainer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!TextUtils.isEmpty(AccountHelper.getComPanyid())) {
                    mClickCallback.clickRader();
                }
            }
        });
        holder.organizationContainer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!TextUtils.isEmpty(AccountHelper.getComPanyid())) {
                       mClickCallback.clickOrganization();
                }
            }
        });
        holder.rankContainer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!TextUtils.isEmpty(AccountHelper.getComPanyid())) {
                    mClickCallback.clickRank();
                }
            }
        });
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.rader_container)
        LinearLayout raderContainer;
        @BindView(R.id.organization_container)
        LinearLayout organizationContainer;
        @BindView(R.id.rank_container)
        LinearLayout rankContainer;
        ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
    public interface  ClickCallback{
         void clickRader();
        void clickOrganization();
        void clickRank();
    }
}
